package wh.排序算法.快速排序;

import java.util.Arrays;

/**
 * @author: wh(1835734390 @ qq.com)
 * @date: 2023/9/26 13:11
 * @description:
 * @version:
 */
public class Test {
    public static void main(String[] args) {
        int[] array = {2,1,4,3,7,3,2};
        quickSort(array,0,array.length - 1,2);
        System.out.println(Arrays.toString(array));
    }

    public static void quickSort(int[] array,int low, int high, int index) {
        while(low <= high) {
            while(low <= high && array[low] <= array[index]) {
                low++;
            }
            while(low <= high && array[high] >= array[index]) {
                high--;
            }
            if (low <= high) {
                // 交换位置
                int temp = array[low];
                array[low] = array[high];
                array[high] = temp;
            }
        }
        int temp = array[high];
        array[high] = array[index];
        array[index] = temp;
    }


}
